package com.liy.framework.common.orm.dialect;

import org.apache.ibatis.session.*;

public class DialectFactory
{
    public static String dialectClass;
    
    public static Dialect buildDialect(final Configuration configuration) {
        if (DialectFactory.dialectClass == null) {
            synchronized (DialectFactory.class) {
                if (DialectFactory.dialectClass == null) {
                    DialectFactory.dialectClass = configuration.getVariables().getProperty("dialectClass");
                }
            }
        }
        Dialect dialect = null;
        try {
            dialect = (Dialect)Class.forName(DialectFactory.dialectClass).newInstance();
        }
        catch (Exception e) {
            e.printStackTrace();
            System.err.println("\u8bf7\u68c0\u67e5 mybatis-config.xml \u4e2d  dialectClass \u662f\u5426\u914d\u7f6e\u6b63\u786e?");
        }
        return dialect;
    }
    
    static {
        DialectFactory.dialectClass = null;
    }
}
